/*
 * EditControls.fx
 *
 * Created on 2009-09-04, 18:37:38
 */

package shmallarchitect.gui;

import javafx.scene.CustomNode;
import javafx.scene.Group;
import javafx.scene.Node;


import javafx.scene.control.Button;

import javafx.scene.transform.Translate;


import javafx.scene.text.Text;

import javafx.scene.paint.Color;
import javafx.scene.text.Font;

import javafx.scene.text.FontWeight;

import shmallarchitect.java.Locuma;

/**
 * @author Administrator
 */

var addLocum: Button = Button { 

           text: "Add/Edit Locum"
           action: function() {

           if(BaseLayout.getLocuma().locumid == 0)
            {
                EditDetails.edit_locum(new Locuma(sizeof(BaseLayout.local_list)));
                EditDetails.resourcelist = [0,0,0];

                EditDetails.namebox.text = "";
                EditDetails.descbox.text = "";
                EditDetails.wwwbox.text = "";
                EditDetails.phonebox.text = "";
  
            }
            else {
                EditDetails.edit_locum(BaseLayout.getLocuma());
                EditDetails.resourcelist = BaseLayout.getLocuma().getResource();
                EditDetails.locumbg = BaseLayout.getLocuma().getLocumcolor();

                EditDetails.namebox.text = BaseLayout.getLocuma().getName();
                EditDetails.descbox.text = BaseLayout.getLocuma().getTextual_desc();
                EditDetails.wwwbox.text = BaseLayout.getLocuma().getWww();
                EditDetails.phonebox.text = BaseLayout.getLocuma().getPhone();

                }



           BaseLayout.mode = not BaseLayout.mode;
           EditDetails.editdetailsmode = not EditDetails.editdetailsmode;

           }

            transforms: [ Translate {x: 90, y: 0 } ]
            visible: bind BaseLayout.editmode and BaseLayout.mode or EditDetails.editdetailsmode;
}

var addOwner: Button = Button {

           text: "Manage Owners"
           action: function() {

           BaseLayout.mode = not BaseLayout.mode;
           OwnerUtil.editowner_mode = not  OwnerUtil.editowner_mode;

            }

            visible: bind BaseLayout.editmode and BaseLayout.mode or OwnerUtil.editowner_mode;
            transforms: [ Translate {x: 90, y: 30 } ]
}

var addResource: Button = Button {

           text: "Manage Resources"
           action: function() {

           BaseLayout.mode = not BaseLayout.mode;
           ResourceUtil.edit_resource = not ResourceUtil.edit_resource;

            }

            visible: bind BaseLayout.editmode and BaseLayout.mode or ResourceUtil.edit_resource;
            transforms: [ Translate {x: 210, y: 30 } ]
}

var editMode: Button = Button {
    text: "Edit Mode"

    action: function() {
            
    BaseLayout.editmode = not BaseLayout.editmode;
    }
    
    visible: bind BaseLayout.mode;

}

var editModeSign: Text = Text {
            y: 50;
            content: "EDIT MODE"
            font: Font.font("Verdana", FontWeight.BOLD, 12);
            fill: Color.web("#a1ec36")
            visible: bind BaseLayout.editmode;
       }

var saveGallery: Button = Button {

           text: "Save Gallery"
           action: function() {

                // Tu idzie zapisywanie galerii

            }

            transforms: [ Translate {x: 900, y: 0 } ]
}



 public class EditControls extends CustomNode {

         public override function create(): Node {
                 return Group {
                         content: [

                            editMode, addLocum, addOwner, addResource,
                            saveGallery, editModeSign,
                                 ]
                        transforms: [
                           Translate {x: 20 y: 710}
                           ]

                 };
         }
 }


